<template>
	<view class="contract-form">
		<image src="https://master.shengejiaju.cn/web/static/images/contract-bg.png" mode="widthFix"></image>
		<view class="contract-form-group">
			<view class="contract-form-cell"><input type="text" placeholder="请输入您的姓名" v-model="form.name" /></view>
			<view class="contract-form-cell"><input type="digit" placeholder="请输入您的手机号码" v-model="form.phone" /></view>
			<view class="contract-form-cell"><input type="idcard" placeholder="请输入您的身份证号码" v-model="form.id_card" /></view>
			<view class="contract-form-cell"><input type="text" placeholder="请输入公司名称" v-model="form.company_name" /></view>
		</view>
		<view class="contract-form-btn"><button type="primary" @click="submit">申请电子合同</button></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {
					is_wx: 1,
					name: '',
					phone: '',
					id_card: '',
					company_name: ''
				}
			};
		},
		methods: {
			submit(){
				this.$api.appContract(this.form).then(res => {
					let keyword = res.datas.keyword
					let no = res.datas.no
					let notify_url = res.datas.notify_url
					let return_url = res.datas.return_url
					let sign_type = res.datas.sign_type
					let sign_val = res.datas.sign_val
					let user_code = res.datas.user_code
					let zqid = res.datas.zqid
					
					
					// let zqid = 'ZQ718B3B51F47A4D14881D6D47B096F91F'
					// let no = 'd8ea0a0ba0984be9bc3de7c0eaf39319'
					// let sign_type = 'SIGNATURE'
					// let user_code = '83004adc5b9b4009bd6837c1be37bf28'
					// let return_url = 'https://sign.zqsign.com/text/return.html'
					// let notify_url = 'http://192.168.1.8:8080/request/notify'
					// let sign_val = "Xr1fHrZYh0YrwrEHfQxwoV66Djgcg0dnfo4K8GiA/ZIH+1FhpPCiEhcoRlIq04xFjJxx9o5tM5QXB7KUDzaDwywHYZy/5NPfGcRM62LRRBp57RWODjKqAN6fIW+rh64fNePFzy37U9B+9oDVrGMUP4zK59W0A0XPVI7CN3c/F6Y=";
					
					//将等号替换为%3d  在中间过渡页面进行替换回等号 get请求获取参数以等号截取。 所以要替换
					sign_val = sign_val.replace("=", "%3d");
					// https://sign.zqsign.com/personReg
					let url = "https://sign.zqsign.com/mobileSignView";  //签约地址
					let parameters = "no=" + no + "&user_code=" + user_code + "&zqid=" + zqid + "&sign_type=" + sign_type + "&notify_url=" + notify_url + "&return_url=" + return_url + "&sign_val=" + sign_val + "&url=" + url + "&value=" + keyword
					console.log("签名请求参数："+ parameters);
					console.log(parameters)
					uni.navigateTo({
						url: '/pages/contract-webview/contract-webview?' + parameters
					})
				})
			}
		}
	}
</script>

<style lang="scss">
	.contract-form{
		image{
			width: 100%;
			vertical-align: top;
		}
		.contract-form-group{
			background-color: #FFF;
			.contract-form-cell{
				padding: 30rpx 20rpx;
				border-top: solid 1px #EEE;
			}
		}
		.contract-form-btn{
			padding: 75rpx;
			button{
				height: 90rpx;
				line-height: 90rpx;
				font-size: 32rpx;
				border-radius: 40rpx;
			}
		}
	}
</style>